#ifndef System_h
#define System_h

#include "Scheduler.h"
#include "Configuration.h"
#include "Node.h"
#include <map>

using std::map;

typedef map<int, Node*> NODES;

class Mailer;
class Node;

class System
{
public:
	System(void);
	~System(void);
	Thread* createThread(void* (*func)(void*), void* arg);
	void config(const char* fileName);
	void addShellsMailbox(int id);
	void start();
	void stop();
	int crashNode(int id);
	int reviveNode(int id);
	void setNodeClock(int id, int newClock);
	void sendNodeClock(int id);
	void killAll();
	int getTotalTime();
	int sendNodeTime(int id);
	int getMaxLength();
	int getInboxMaxLength(int id);
	int getNumOfSteps();
	int getNumOfNodes();
	Message* recieve(int id);
	int SendSyncMsg(int source, int nodeId, int counter=0);
	int getNodeStatus(int nodeId);
	void startTimer();
	void stopTimer();
	int m_numOfSteps;
	int getMailboxSize(int id);
	void startAll();

private:
	NODES* m_nodes;
	Mailer* m_mailer;
	Scheduler* m_scheduler;
	Configuration* m_config;
	bool m_ready;

	void changePolicy(int policy);
	int getThreadID(int nodeID);
};

#endif
